<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
	<!-- 版权 -->
	<div class="col-lg-12 text-center bg-info navbar-fixed-bottom">
		<h5>版权所有&copy;蜗牛图书商城</h5>
	</div>
</body>
<script type="text/javascript">
	function addCart(gid, oinum) {
		if ("${loginUser.ucartid}" == "" || "${loginUser.ucartid}" == 0) {
			alert("请登录商城用户账号！");
			location.reload();
			return;
		}
		if (oinum == null || oinum == "" || parseInt(oinum) < 1) {
			oinum = 1;
		}
		$.ajax({
			url : "orderInfo",
			type : "post",
			data : {
				"opr" : "addCartInfo",
				"gid" : gid,
				"oinum" : oinum,
			},
			dataType : "JSON",
			success : function(result) {
				if (result.msg == "ok") {
					if (confirm("商品已加入购物车,是否前往购物车查看？")) {
						location.href = "cart.jsp";
					}
				} else if (result.msg == "null") {
					alert("请登录商城用户账号！");
					location.reload();
				} else {
					alert(result.msg);
					location.reload();
				}
			}
		})
	}

	function buy(gid, oinum) {
		if ("${loginUser.ucartid}" == "" || "${loginUser.ucartid}" == 0) {
			alert("请登录商城用户账号！");
			location.reload();
			return;
		}
		if (oinum == null || oinum == "" || parseInt(oinum) < 1) {
			oinum = 1;
		}
		$.ajax({
			url : "orderForm",
			type : "post",
			data : {
				"opr" : "buyNow",
				"gid" : gid,
				"oinum" : oinum,
			},
			dataType : "JSON",
			success : function(result) {
				if (result.msg == "ok") {
					location.href = "creatOrderForm.jsp";
				} else if (result.msg == "null") {
					alert("请登录商城用户账号！");
					location.reload();
				} else {
					alert(result.msg);
					location.reload();
				}
			}
		})
	}
</script>
</html>
